<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMybankBatchNoRecordTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mybank_batch_no_record', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('billRecordId')->default(0)->comment('账单记录 ID');
            $table->string('channelType',24)->default('')->comment('渠道类型 WXPAY,ALIPAY');
            $table->string('tradeType',24)->default('')->comment('SINGLE_PAY 支付明细,REFUND 退款明细（不支持）,FEE 费用,SUBSIDY 补贴');
            $table->string('batchNo',24)->default('')->comment('批次号');
            $table->string('reconDt',24)->default('')->comment('对账日');
            $table->string('mybankOrderNo',128)->default('')->comment('网商订单号');
            $table->string('outTradeNo',128)->default('')->comment('isv支付单号');
            $table->string('channelTradeNo',128)->default('')->comment('渠道支付单号');
            $table->string('outRefundNo',128)->default('')->comment('isv退款单号');
            $table->string('channelRefundNo',128)->default('')->comment('渠道退款单号');
            $table->unsignedInteger('tradeAmount')->default(0)->comment('交易总金额,单位（分）');
            $table->unsignedInteger('actualAmount')->default(0)->comment('实际金额,单位（分）');
            $table->unsignedInteger('channelFeeAmount')->default(0)->comment('渠道手续费');
            $table->string('ccy',24)->default('')->comment('币种');
            $table->string('userId',128)->default('')->comment('用户标识');
            $table->string('merchantId',128)->default('')->comment('商户号');
            $table->string('status',128)->default('')->comment('交易状态');
            $table->string('remark',255)->default('')->comment('备注');
            $table->unsignedInteger('createTime')->default(0)->comment('创单时间');
            $table->unsignedInteger('tradeTime')->default(0)->comment('交易时间');
            $table->string('acquireId',128)->default(0)->comment('收单机构编号');
            $table->tinyInteger("flagMark")->default(0)->comment("是否匹配 0:未匹配,1:已匹配");
            $table->tinyInteger("type")->default(1)->comment("类型 1美团 2 饿了么 3堂食");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->index('batchNo','idx_batchNo');
            $table->index('merchantId','idx_merchantId');
            $table->comment = '对账文件批次号信息记录';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mybank_batch_no_record');
    }
}
